package com.im.client.lib;

import android.util.Log;

public abstract class MessageClient {

	private ImClientLib imClientLib;

	public MessageClient() {
		imClientLib = new ImClientLib(this);
	}

	public void setUerInfo(String username, String password) {
		imClientLib.setUserInfo(username, password);
	}

	public void setNetInfo(String host, int port) {
		imClientLib.setNetInfo(host, port);
	}
	public void setKeepLive(long time){
		imClientLib.setKeepLive(time);
	}

	public void start() {
		new Thread() {
			public void run() {
				if (imClientLib != null) {
					imClientLib.start();
				}

			};
		}.start();
	}

	public void close() {
		new Thread() {

			public void run() {
				if (imClientLib != null) {
					imClientLib.close();
					Log.d("close", String.valueOf(imClientLib.close()));
				}

			};
		}.start();

	}

	public void sendMessage(final String to, final String message) {
		new Thread() {
			public void run() {
				if (imClientLib != null) {
					Log.d("send", String.valueOf(imClientLib.sendMessage(to,message)));
				}

			};

		}.start();
	}
	public abstract   void headleInfo(String info);
	public abstract   void receiveMessage(String from,byte[] msg);

}
